<?php
namespace mvc\validator;

class UniqueValidator extends Validator
{
    public function validate()
    {
        $attribute = $this->attribute;
        $value = $this->value;
        if($this->model->where("$attribute='$value'")->count()) {
            $this->message = $this->attributeLabel . '已被使用或注册';
            return false;
        }
        return true;
    }

    public function getMessage()
    {
        return $this->message;
    }
}